package com.bruce.pattern.behavioral.strategy;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by bruce on 2018/11/10 15:45
 */
public final class PromotionStrategyFactory {

    private static final Map<String, PromotionStrategy> strategyMap = new HashMap<>();

    private static final EmptyPromotionStrategy emptyPromotionStrategy = new EmptyPromotionStrategy();

    static {
        strategyMap.put(PromotionType.FAN_XIAN, new FanXianPromotionStrategy());
        strategyMap.put(PromotionType.LI_JIAN, new LiJianPromotionStrategy());
        strategyMap.put(PromotionType.MAN_JIAN, new ManJianPromotionStrategy());
    }

    private PromotionStrategyFactory() {

    }

    public static PromotionStrategy getStrategy(String promotionType) {
        PromotionStrategy promotionStrategy = strategyMap.get(promotionType);
        return promotionStrategy == null ? emptyPromotionStrategy : promotionStrategy;
    }

    public interface PromotionType{
        public static final String MAN_JIAN = "manjian";
        public static final String LI_JIAN = "lijian";
        public static final String FAN_XIAN = "fanxian";
    }


}
